package com.ruoyi.account.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
public enum WeiXinUserIdEnum {

    REN(3, "RenChuangQuan", "任创权"),
    ZHOU(2,"swag", "周浩"),
    ZHU(1,"552a37f926e5256f3f4963727accd401", "祝嘉宏"),
    GONG(0,"552a37f926e5256f3f4963727accd401", "对公"),
    ;

    Integer id;
    String value;
    String name;

    WeiXinUserIdEnum(Integer id,String value, String name){
        this.id = id;
        this.value = value;
        this.name = name;
    }

    public static String getLabelByValue(Integer value) {
        for (WeiXinUserIdEnum item : values()) {
            if (ObjectUtil.equals(item.getValue(), value)){
                return item.getName();
            }
        }
        return value+"";
    }

    public static WeiXinUserIdEnum getEntityByValue(Integer id) {
        for (WeiXinUserIdEnum item : values()) {
            if (ObjectUtil.equals(item.getId(), id)){
                return item;
            }
        }
        return ZHU;
    }

    public static List<Map<String, String>> getListMap() {
        List<Map<String, String>> listMap = new ArrayList<>();
        for (WeiXinUserIdEnum item : values()) {
            Map<String, String> itemMap = new HashMap<>();
            itemMap.put("name", item.getName());
            itemMap.put("value", String.valueOf(item.getValue()));
            itemMap.put("id", String.valueOf(item.getId()));
            listMap.add(itemMap);
        }
        return listMap;
    }

}
